/*
 * @Description: 预加载
 * @param : 
 */
$(function (){
	var id = $("#id").val();
//	var type = $("#type").val();
//	var data = $("#data").val();
//	console.log(data)
	$.ajax({
		url:pathUrl("dispatch/findByCondition.action"),
		type:'POST',
		dataType:'JSON',
		data:{'id' : id},
		success:function(data){
			console.log(data)
			var str = "";
			data = data.rows[0];
			str = toUtf8(data.fCode);
			
			var key, value;
			for (x in data) {//往span里写值
				key = x;
				value = data[x] == null?"":data[x];
				if(x == 'fStartTime' || x == 'fEndTime'){
					value = dateFormatter(data[x]);
				}
				$("#"+key).text(value);
			}
			
			$("#qrcode").qrcode({
				width: 110,
				height: 110,
				correctLevel : 3,
				text: str
			});
			setTimeout(function(){
				print();
			}, 500);
		}
	});
});

/*
 * @Description: 打印
 * @param :
 */
function print() {
	var canvas=document.getElementsByTagName("canvas")[0];
	var dataURL = canvas.toDataURL("image/png");
	var img = '<img src="'+dataURL+'"></img>';
	$("#qrcode").html(img);
	$(".row").print({
		deferred: $.Deferred().done(function() { window.close(); })//打印完后自动关闭打印页面
	});
}